package cn.edu.xmu.javaee.chapter2.beanlifecycle.config;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.Locale;

@Configuration
@ConfigurationProperties("beanlifecycle")
public class ApplicationConfig implements InitializingBean {

    private String locale;

    private Locale localeObj;


    @Override
    public void afterPropertiesSet() throws Exception {
        this.localeObj = new Locale(this.locale);
    }

    public Locale getLocale(){
        return this.localeObj;
    }

    public void setLocale(String locale){
        this.locale = locale;
    }
}
